package com.example.cinema.fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.example.cinema.R;
import com.example.cinema.bindingdata.AdverItemData;
import com.example.cinema.bindingdata.Advert;
import com.example.cinema.databinding.AdverItemViewBinding;

public class AdverItemFragment extends Fragment {

    private AdverItemViewBinding AIVB;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        AIVB = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.adver_item_view,container,false);

        return AIVB.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        AdverItemData itemData = new AdverItemData();
        if(advert !=null)
        {
            Log.i("cccc",advert.adverurl);
            Log.i("cccc",advert.adverskip);
            itemData.images.set(advert.adverurl);
            itemData.skipurl.set(advert.adverskip);
        }

        AIVB.setAdveritemdata(itemData);
    }

    private static Advert advert;
    public void setData(Advert advert)
    {
        this.advert = advert;
    }
}
